package cn.itcast.web.servlet;

import cn.itcast.domain.Req;
import cn.itcast.service.ReqService;
import cn.itcast.service.impl.ReqServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findReqByIdAndYidServlet")
public class FindReqByIdAndYidServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1获取参数
        String id = request.getParameter("id");
        String yid = request.getParameter("yid");
        //2调用service查询
        ReqService service=new ReqServiceImpl();
        Req req=service.findReqByIdAndYid(id,yid);
        //2存入request域中
        request.setAttribute("req",req);
        //3转发到Reqlist.jsp中
        request.getRequestDispatcher("/Requpdate.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
